<template>
  <template v-if="$cfg.mobile == false">
    <n-pagination
      v-model:page="props.page"
      @update:page="set.hand"
      :page-count="Math.ceil(count / (limit ?? 20))"
    />
  </template>
  <template v-else>
    <van-pagination
      v-model="props.page"
      @change="set.hand"
      :total-items="count"
      :items-per-page="limit ?? 20"
    >
      <template #prev-text>
        <div class="_prev"><van-icon name="arrow-left" /></div>
      </template>
      <template #next-text>
        <div class="_prev"><van-icon name="arrow" /></div>
      </template>
    </van-pagination>
  </template>
</template>
<script>
export default {
  //获取@ck事件
  emits: ["ck"],
  props: {
    page: {
      type: Number,
      required: true,
    },
    count: {
      type: Number,
      required: false,
    },
    limit: {
      type: Number,
      required: false,
    },
  },
  setup(props, { emit }) {
    const set = {
      hand: (page) => {
        emit("ck", page);
      },
    };
    return {
      props,
      set,
    };
  },
};
</script>
